Cover | TOC | Chap | Prev Chap | Prev Fig | Next Fig | Next Chap |
|
Figure 27.3
An orb that animates when the viewer collides with its box proxy shape. |
|
Click on the image to view the VRML scene. |
#VRML V2.0 utf8 # The VRML 2.0 Sourcebook # Copyright (c) 1997 # Andrea L. Ames, David R. Nadeau, and John L. Moreland Group { children [ NavigationInfo { headlight FALSE avatarSize [ 1.0, 1.0, 0.75 ] }, # Floor (two strips) Transform { translation 0.0 0.0 2.5 children DEF Floor Inline { url "dfloor.wrl" } }, Transform { translation 0.0 0.0 -2.5 children USE Floor }, # Collision group DEF OrbCollide Collision { proxy Transform { translation 0.0 0.6 0.0 children Shape { geometry Box { size 0.4 1.2 0.4 } } } children [ # Glowing orb with sound effects DEF OrbSpin Transform { translation 0.0 1.0 0.0 children [ # Orb light PointLight { location 0.3 0.0 0.0 radius 10.0 ambientIntensity 0.2 color 0.7 0.5 0.0 }, # Orb itself Shape { appearance Appearance { # No material, use emissive texturing texture ImageTexture { url "fire.jpg" } } geometry Sphere { radius 0.2 } }, # Orb sounds Sound { source AudioClip { url "drone1.wav" loop TRUE } intensity 0.5 }, DEF WispyAmp Sound { source DEF Wispy AudioClip { url "willow1.wav" stopTime 1.0 } intensity 0.0 } ] }, # Pedestal pyramid Shape { appearance DEF PedestalColor Appearance { material Material { } } geometry IndexedFaceSet { coord Coordinate { point [ # Around the base -0.12 0.03 0.12, 0.12 0.03 0.12, 0.12 0.03 -0.12, -0.12 0.03 -0.12, # Tip 0.0 0.63 0.0, ] } coordIndex [ 0, 1, 4, -1, 1, 2, 4, -1, 2, 3, 4, -1, 3, 0, 4, -1, ] solid TRUE } }, # Pedestal base Transform { translation 0.0 0.015 0.0 children Shape { appearance USE PedestalColor geometry Box { size 0.4 0.03 0.4 } } }, ] } # Animation clock DEF Clock TimeSensor { cycleInterval 28.0 }, # Orb animation and volume control DEF OrbSpinner OrientationInterpolator { key [ 0.0, 0.5, 1.0 ] keyValue [ 0.0 1.0 0.0 0.0, 0.0 1.0 0.0 3.14, 0.0 1.0 0.0 6.28 ] }, DEF WispyVolume ScalarInterpolator { key [ 0.0, 0.1, 0.9, 1.0 ] keyValue [ 0.0, 0.6, 0.6, 0.0 ] } ] } ROUTE OrbCollide.collideTime TO Clock.set_startTime ROUTE OrbCollide.collideTime TO Wispy.set_startTime ROUTE Clock.fraction_changed TO OrbSpinner.set_fraction ROUTE Clock.fraction_changed TO WispyVolume.set_fraction ROUTE OrbSpinner.value_changed TO OrbSpin.set_rotation ROUTE WispyVolume.value_changed TO WispyAmp.set_intensity